<?php

$host = "p50mysql53.secureserver.net";
$user = "jeegoon";
$pswd = "Myproject2008";
$db = "jeegoon";

// Set authorization to False

$authorization = 0;
$errorsinfo = "";
// Verify that user has entered username and password

print $PHP_AUTH_USER;
print $PHP_AUTH_PW;


if (isset($PHP_AUTH_USER) && isset($PHP_AUTH_PW)) :

  mysql_pconnect($host, $user, $pswd) or die("Can't connect to MySQL
server!");

  mysql_select_db($db) or die("Can't select database!");

  // Perform the encryption
  $salt = substr($PHP_AUTH_PW, 0, 2);
  $encrypted_pswd = crypt($PHP_AUTH_PW, $salt);

  // Build the query

  $query = "SELECT Name FROM member WHERE Name = '" . $PHP_AUTH_USER . "' AND Password = '" . $encrypted_pswd . "'";
  $errorsinfo = $query;
  print $query;
  print $errorsinfo ;
  // Execute the query

//  if (mysql_numrows(mysql_query($query)) == 1) :
    $authorization = 1;
//  endif;

endif;

// confirm authorization

if (! $authorization) :

  header('WWW-Authenticate: Basic realm="Private"');
  header('HTTP/1.0 401 Unauthorized');
  print "You are unauthorized to enter this area.";
  print $errorsinfo ;
  print "11";
  
  print $query;
  print $encrypted_pswd;
  exit;

else :

  print "This is the secret data!";
  
  print $errorsinfo ;
  print "22";
  
  print $query;
  print $encrypted_pswd;

endif;

?>
